
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.JTextField;


import javax.swing.*;

public class StatisticsView extends JPanel implements ActionListener
{
	
	DobbelsteenModel d;	
	
	private int waarde;		
	
	private int one;
	private int two;
	private int three;
	private int four;
	private int five;
	private int six;
	
	private int total;
	
	private JTextField totalText = new JTextField();
	private JTextField oneText = new JTextField();
	private JTextField twoText = new JTextField();
	private JTextField threeText = new JTextField();
	private JTextField fourText = new JTextField();
	private JTextField fiveText = new JTextField();
	private JTextField sixText = new JTextField();	
	
	public StatisticsView(){
		setLayout(new GridLayout(7,1));	
		add(totalText);
		add(oneText);		
		add(twoText);
		add(threeText);
		add(fourText);
		add(fiveText);
		add(sixText);			 
	}
	
	public void actionPerformed( ActionEvent e )
	{
	    d = (DobbelsteenModel) e.getSource();	    
	    this.waarde = d.getWaarde();
	    this.setCounted();
	    
	    totalText.setText(total + " worpen");
	    oneText.setText("1: " + one + "keer");
	    twoText.setText("2: " + two + "keer");
	    threeText.setText("3: " + three + "keer");
	    fourText.setText("4: " + four + "keer");
	    fiveText.setText("5: " + five + "keer");
	    sixText.setText("6: " + six + "keer");
	    
	    
	}
	
	public void setCounted(){
		switch(waarde) {
		case 1: one++;
		break;
		case 2: two++;
		break;
		case 3: three++;
		break;
		case 4: four++;
		break;
		case 5: five++;
		break;
		case 6: six++;
		}
		total ++;
	}
	
	public Dimension getPrefferedSize()
	{
		 return new Dimension(100,80);
	}
	
	
}